package com.arellomobile.android.push;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import com.arellomobile.android.push.utils.GeneralUtils;
import java.io.PrintStream;

public class PushEventsTransmitter
{
  private static boolean getUseBroadcast(Context paramContext)
  {
    try
    {
      ApplicationInfo localApplicationInfo = paramContext.getPackageManager().getApplicationInfo(paramContext.getApplicationContext().getPackageName(), 128);
      if (localApplicationInfo.metaData != null)
      {
        boolean bool = localApplicationInfo.metaData.getBoolean("PW_BROADCAST_REGISTRATION", true);
        System.out.println("Using broadcast registration: " + bool);
        return bool;
      }
      return true;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return true;
  }

  static void onMessageReceive(Context paramContext, String paramString)
  {
    onMessageReceive(paramContext, paramString, null);
  }

  static void onMessageReceive(Context paramContext, String paramString, Bundle paramBundle)
  {
    transmit(paramContext, paramString, "PUSH_RECEIVE_EVENT", paramBundle);
  }

  static void onRegisterError(Context paramContext, String paramString)
  {
    if (getUseBroadcast(paramContext))
    {
      transmitBroadcast(paramContext, paramString, "REGISTER_ERROR_EVENT");
      return;
    }
    transmit(paramContext, paramString, "REGISTER_ERROR_EVENT");
  }

  static void onRegistered(Context paramContext, String paramString)
  {
    if (getUseBroadcast(paramContext))
    {
      transmitBroadcast(paramContext, paramString, "REGISTER_EVENT");
      return;
    }
    transmit(paramContext, paramString, "REGISTER_EVENT");
  }

  static void onUnregistered(Context paramContext, String paramString)
  {
    if (getUseBroadcast(paramContext))
    {
      transmitBroadcast(paramContext, paramString, "UNREGISTER_EVENT");
      return;
    }
    transmit(paramContext, paramString, "UNREGISTER_EVENT");
  }

  static void onUnregisteredError(Context paramContext, String paramString)
  {
    if (getUseBroadcast(paramContext))
    {
      transmitBroadcast(paramContext, paramString, "UNREGISTER_ERROR_EVENT");
      return;
    }
    transmit(paramContext, paramString, "UNREGISTER_ERROR_EVENT");
  }

  private static void transmit(Context paramContext, String paramString1, String paramString2)
  {
    transmit(paramContext, paramString1, paramString2, null);
  }

  private static void transmit(Context paramContext, String paramString1, String paramString2, Bundle paramBundle)
  {
    Intent localIntent = new Intent(paramContext, MessageActivity.class);
    if (paramBundle != null)
      localIntent.putExtras(paramBundle);
    localIntent.putExtra(paramString2, paramString1);
    localIntent.setFlags(268435456);
    paramContext.startActivity(localIntent);
  }

  private static void transmitBroadcast(Context paramContext, String paramString1, String paramString2)
  {
    String str = paramContext.getPackageName();
    Intent localIntent = new Intent(str + "." + "com.arellomobile.android.push.REGISTER_BROAD_CAST_ACTION");
    localIntent.putExtra(paramString2, paramString1);
    localIntent.setPackage(str);
    if (GeneralUtils.checkStickyBroadcastPermissions(paramContext))
    {
      paramContext.sendStickyBroadcast(localIntent);
      return;
    }
    Log.w(PushEventsTransmitter.class.getSimpleName(), "No android.permission.BROADCAST_STICKY. Reverting to simple broadcast");
    paramContext.sendBroadcast(localIntent);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.arellomobile.android.push.PushEventsTransmitter
 * JD-Core Version:    0.6.2
 */